/////////////////////////////////////////////////////////////////////////////
// Filename: Color.h
// Description: Simple RGB color class
/////////////////////////////////////////////////////////////////////////////

#ifndef COLOR_H
#define COLOR_H

class Color {
public:
	float r,g,b;

public:
	//default color = black
	Color () {r=g=b=0;}
	Color (float rr, float gg, float bb):r(rr),g(gg),b(bb) {}
	Color (Color const &c):r(c.r),g(c.g),b(c.b) {}

	//relation operators
	bool operator ==(const Color &p) const {
		return ((r==p.r)&&(g==p.g)&&(b==p.b));
	}

	bool operator !=(const Color &p) const {
		return !((*this)==p);
	}

	//simple arithmetics
	Color operator +(Color const &c) const {
		return Color(r+c.r,g+c.g,b+c.b);
	}  

	Color operator -(Color const &c) const {
		return Color(r-c.r,g-c.g,b-c.b);
	}  

	Color operator -() const {
		return Color(-r,-g,-b);
	}  

	Color operator *(float d) const {
		return Color(r*d,g*d,b*d);
	}

	Color operator /(float d) const {
		return Color(r/d,g/d,b/d);
	}

	Color &operator +=(Color const &c) {
		r+=c.r;
		g+=c.g;
		b+=c.b;
		return *this;
	}  

	Color &operator -=(Color const &c) {
		r-=c.r;
		g-=c.g;
		b-=c.b;
		return *this;
	}  

	Color &operator *=(float d) {
		r*=d;
		g*=d;
		b*=d;
		return *this;
	}

	Color &operator /=(float d) {
		r/=d;
		g/=d;
		b/=d;
		return *this;
	}

	//elementwise multiplication
	Color &operator *=(Color const &c) {
		r*=c.r;g*=c.g;b*=c.b;return *this;
	}

	Color operator *(Color const &c) const {
		return Color(r*c.r,g*c.g,b*c.b);
	}
};

//wrong order multiplication
inline Color operator *(float d, Color const &c) {
	return c*d;    
}  

#endif

/////////////////////////////////////////////////////////////////////////////
//                               END OF FILE                               //
/////////////////////////////////////////////////////////////////////////////
